import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import { LayoutComponent } from '../layout/layout.component';

import { BearingComponent } from './bearing.component';
import { BearingListComponent } from './bearing-list.component';
import { BearingDetailComponent } from './bearing-detail.component';
import { BearingAddComponent } from './bearing-add.component';
import { PlaceholderComponent } from './placeholder.component';

import { AuthGuard } from '../auth-guard';
import { AuthService } from '../scheme/auth.service';

const bearingRoutes: Routes = [
	{
		path: 'admin',
		component: LayoutComponent,
		canActivateChild: [AuthGuard],
		children: [{
			path: 'bearing',
			component: BearingComponent,
			children: [
				{
					path: '',
					redirectTo: '/admin/bearing/list',
					pathMatch: 'full'
				},
				{
					path: 'list',
					component: BearingListComponent,
					children: [
						{
							path: '',
							component: PlaceholderComponent
						},
						{
							path: ':id',
							component: BearingDetailComponent
						}
					]
				},
				{
					path: 'add',
					component: BearingAddComponent
				}
			]
		}]
	}
];

export const bearingRoutingProviders: any[] = [
    AuthGuard,
    AuthService
];

export const bearingRouting: ModuleWithProviders = RouterModule.forChild(bearingRoutes);